﻿Imports DAO
Imports System.Data
Imports System.Data.OleDb
Imports DTO

Public Class DanhSachKhamBenhBUS
    Public Function INSERT(ByVal hoten As String, ByVal diachi As String, ByVal gioitinh As String, ByVal ngaysinh As Date, ByVal ngaykham As Date) As Integer
        Dim DSBN As New DanhSachKhamBenhDAO()
        Dim DSKB As New DanhSachKhamBenh_DTO()
        If (hoten.Length < 1 Or hoten = "") Then
            Return 2

        End If
        If (diachi.Length < 1 Or diachi = "") Then
            Return 2
        End If
        Try
            DSKB.HoTen = hoten
            DSKB.DiaChi = diachi
            DSKB.GioiTinh = gioitinh
            DSKB.NgayKham = ngaykham
            DSKB.NamSinh = ngaysinh
        Catch ex As Exception
            Return 2
            'du~ lieu bi loi~
        End Try
        Dim soluongbenhnhantrongngay As Integer
        soluongbenhnhantrongngay = DSBN.SoLuong(DSKB)
        If (soluongbenhnhantrongngay >= 40) Then
            ' return -1 tux la da~ day benh nhan
            Return -1
        Else
            Dim temp As Integer
            temp = DSBN.INSERT(DSKB)

            Return temp
            'temp=1 la them dc
            'temp=0 la them 0 dc
        End If

    End Function


End Class
